<html>
<head><meta charset="utf-8"><title>Iterator API for Backtrace · project-error-handling · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/index.html">project-error-handling</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html">Iterator API for Backtrace</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212763829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/212763829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#212763829">(Oct 08 2020 at 23:57)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="204346">@Ashley Mannix</span>, if we want to get the ball rolling on implementing an iterator API for the <code>Backtrace</code> type, what would the first steps be for that? <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="213068641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/213068641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#213068641">(Oct 12 2020 at 17:59)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="300743">@Sean Chen</span>! Sorry for the late reply <span aria-label="blush" class="emoji emoji-1f60a" role="img" title="blush">:blush:</span> I was on leave last week. Are you talking about an iterator over the frames in the backtrace itself?</p>



<a name="213068707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/213068707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#213068707">(Oct 12 2020 at 18:00)</a>:</h4>
<p>yes</p>



<a name="214204354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214204354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214204354">(Oct 22 2020 at 15:33)</a>:</h4>
<p>Following up on this task. From last week’s meeting we mentioned that we could look into simply re-exporting the <code>frames</code> method from the <code>backtrace</code> crate into <code>std</code>. Apologies if this is a bit of an obtuse question, but how should we go about getting the ball rolling on this? 🙂</p>



<a name="214204535"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214204535" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214204535">(Oct 22 2020 at 15:34)</a>:</h4>
<p>In the minutes doc from the last meeting we wrote down “Add it as an unstable API to <code>Backtrace</code> without an RFC to start with (just an FCP on the implementation itself)”. I’m not sure what an FCP is or how to get one started.</p>



<a name="214206226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214206226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214206226">(Oct 22 2020 at 15:46)</a>:</h4>
<p>I think you just need to open a PR</p>



<a name="214206262"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214206262" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214206262">(Oct 22 2020 at 15:46)</a>:</h4>
<p>and then the FCP is something that a libs team member triggers on the PR</p>



<a name="214206288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214206288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214206288">(Oct 22 2020 at 15:47)</a>:</h4>
<p><span class="user-mention" data-user-id="204346">@Ashley Mannix</span> correct me if I'm wrong</p>



<a name="214207194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214207194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214207194">(Oct 22 2020 at 15:53)</a>:</h4>
<p>Would that be a PR in <code>std</code> or in the <code>Backtrace</code> crate?</p>



<a name="214271014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214271014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214271014">(Oct 23 2020 at 03:52)</a>:</h4>
<p>Sorry! Just catching up on things <span aria-label="bow" class="emoji emoji-1f647" role="img" title="bow">:bow:</span> Yep! Like <span class="user-mention" data-user-id="220273">@Jane Lusby</span> mentioned, we'd do a PR to <code>rust-lang/rust</code>'s <code>Backtrace</code> type with an API that looked something like this (pseudo attributes because I never remember the exact syntax off the top of my head):</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="c1">// This type already exists, but is private</span>
<span class="cp">#[unstable(feature = </span><span class="s">"backtrace_frames"</span><span class="cp">)]</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">BacktraceFame</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="w"> </span><span class="n">Backtrace</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="c1">// This is a new method. We'll have some semantics to work out (do we return `&amp;[]` when the backtrace is unsupported? Or make it `Option`)?</span>
<span class="w">    </span><span class="cp">#[unstable(feature = </span><span class="s">"backtrace_frames"</span><span class="cp">)]</span><span class="w"></span>
<span class="w">    </span><span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">frames</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kp">&amp;</span><span class="p">[</span><span class="n">BacktraceFrame</span><span class="p">];</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="214271035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214271035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214271035">(Oct 23 2020 at 03:53)</a>:</h4>
<p>Feel free to open the PR up early <span class="user-mention" data-user-id="300743">@Sean Chen</span> if you like and add a <code>r? @KodrAus</code> comment so it'll assign me and we can work through anything that comes up <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<a name="214271083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214271083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ashley Mannix <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214271083">(Oct 23 2020 at 03:54)</a>:</h4>
<p>Or just drop a link and I'll assign myself to it <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="214315416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257204-project-error-handling/topic/Iterator%20API%20for%20Backtrace/near/214315416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Chen (he/him) <a href="https://rust-lang.github.io/zulip_archive/stream/257204-project-error-handling/topic/Iterator.20API.20for.20Backtrace.html#214315416">(Oct 23 2020 at 13:50)</a>:</h4>
<p>Thanks for the pointers! <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>